package com.example.demo.consumer.receiver;

import com.example.demo.common.domain.ChannelRead;
import com.example.demo.consumer.service.ListenerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Auther Created by l.wang on 2019/4/3.
 */
@Component
public class ActiveMqListener {

    @Autowired
    private ListenerService listenerService;

    private ExecutorService service = Executors.newCachedThreadPool();

    private Executor getExecutors(){
        return service;
    }

    @JmsListener(destination = "test_activemq",containerFactory = "myFactory")
    public void receiver(ChannelRead str){
        System.out.println("接收："+Thread.currentThread().getName());
        service.execute(()->listenerService.disPoseService(str));
//        listenerService.disPoseService(str);
    }


}
